package com.jinsi.controller;

import com.jinsi.pojo.Folder;
import com.jinsi.pojo.TreeNode;
import com.jinsi.service.FolderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/folder")
public class FolderController {


    @Autowired
    private FolderService folderService;

    @RequestMapping("/add")
    public Map<String,String> addFolder(Folder folder){
        System.out.println(folder);
        Map<String,String> map = new HashMap<>();
        try {
            folderService.addFolder(folder);
            map.put("msg","成功");
            map.put("state","200");

        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }


    @RequestMapping("/getTree")
    public List<TreeNode> getTree(Integer equpid,String equipname){

        System.out.println(equpid+equipname);
        List<TreeNode> list=  folderService.getTreeData(equpid,equipname);


        return list;
    }
}
